@php
    $function = [];
    if(!empty($model->function)){
        foreach ($model->function as $functionId){
            $function[] = \App\Models\Product\ProductSupplierM::$_function[$functionId];
        }
    }
    $functionStr = !empty($function) ? implode(',', $function) : '';
@endphp
@if($model->audit_status == 2)
    {{ $functionStr }}
@else
    <a class="grid-function-modal" href="#"
       data-id="{{ $model->id }}"
       data-action="updateFunction">
        @if(!$functionStr)
            <i class='fa fa-pencil'></i>
        @else
            {{ $functionStr }}
        @endif
    </a>
@endif
<div class="modal fade" id="functionModal" tabindex="-1">
    <div class="modal-dialog" style="width: 80%;">
        <div class="modal-content">
            <!-- 内容会加载到这里 -->
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.grid-function-modal').on('click', function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            var action = $(this).data('action');
            $("#functionModal").modal({
                remote : '/xqc/products/material-supplier-modal?action=' + action + '&param=' + id
            });
        });
        $("#functionModal").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();
        });
    });
</script>
